/*
 * 原版接口
 */
import * as server from "@minecraft/server";
/*
 * 蛋白石数据
 */
import * as data_entity from "../data/entity";
/*
 * 蛋白石组件
 */
import * as derived_tools from "../system/derived_tools";
import * as native_tools from "../system/native_tools";
import * as achieve_plan from "../system/achieve_plan";
import * as math_tools from "../system/math_tools";
/**
 * * 末影龙属性强化
 * 
 * @param {server.Entity} dragon - 末影龙
 * 
 * @param {server.Player} player - 玩家对象
 * 
 * @param {string} damage - 伤害值
 * 
 * @param {string} type - 伤害类型
 */
export function EnhanceEnderDragon(dragon: server.Entity, player: server.Entity, damage: number, type: server.EntityDamageCause) {
    /**
     * * 末影龙鳞剩余数量
     */
    const scalelike = dragon.getDynamicProperty('entity:ender_dragon_scales') as number ?? 15;
    // 检测 龙鳞数量
    if (scalelike < 1) return;
    // 为玩家显示一次攻略提示
    if (scalelike == 15 && player instanceof server.Player) derived_tools.PlayPrompt(player, '末影龙强化');
    // 检测 伤害类型
    switch (type) {
        //* 爆炸伤害 剥落龙鳞
        case 'entityExplosion':
        case 'blockExplosion':
            EliminateEnderDragonScales(dragon, scalelike);
            break;
        //* 其余伤害 触发反击
        default:
            EnderDragonRetaliate(dragon, player, damage);
            break;
    }
};
/**
 * * 剥离 末影龙鳞
 * 
 * @param {server.Entity} dragon - 末影龙
 * 
 * @param {number} scalelike - 末影龙剩余的龙鳞数量
 */
function EliminateEnderDragonScales(dragon: server.Entity, scalelike: number) {
    //* 检测 龙鳞剥落冷却
    if (!achieve_plan.ControlEventTrigger.EntityToken('龙鳞剥落冷却', dragon, 40)) return;
    /**
     * * 玩家查询选项
     */
    const playerOptions: server.EntityQueryOptions = {
        location: dragon.location,
        maxDistance: 64,
        closest: 5
    };
    /**
     * * 实体效果选项
     */
    const effectOptions: server.EntityEffectOptions = {
        amplifier: 3,
        showParticles: true
    };
    /**
     * * 末影龙鳞 物品对象
     */
    const item = new server.ItemStack("item_template:ender_dragon_scales");
    /**
     * * 获取 玩家队列
     */
    const players = dragon.dimension.getPlayers(playerOptions);
    /**
     * * 持续时间
     */
    const duration = scalelike * players.length * 20;
    /**
     * * 损耗 末影龙鳞
     */
    const consume = Math.floor(scalelike - players.length);
    // 遍历 玩家队列
    players.forEach(
        player => {
            switch (math_tools.Random({ min: 0, max: 2 }, true)) {
                case 0: player.addEffect("absorption", duration, effectOptions); break;

                case 1: player.addEffect("resistance", duration, effectOptions); break;

                case 2: player.addEffect("strength", duration, effectOptions); break;
            };
            // 生成 物品对象
            native_tools.TrySpawnItem(dragon.dimension, item, player.location);
            // 发送 玩家消息
            player.onScreenDisplay.setTitle(`§l§e< 龙鳞剥离 >§r\n§7剩余龙鳞: ${consume}`);
        }
    );
    console.error(scalelike, players.length);
    // 更新 动态属性
    dragon.setDynamicProperty('entity:ender_dragon_scales', consume);
};
/**
 * * 末影龙反击
 * 
 * @param {server.Entity}  dragon - 末影龙
 * 
 * @param {server.Entity} player - 发动攻击的玩家
 * 
 * @param {number} damage - 玩家造成的伤害值
 */
function EnderDragonRetaliate(dragon: server.Entity, player: server.Entity, damage: number) {
    /**
     * * 实体效果选项
     */
    const effectOptions_0: server.EntityEffectOptions = {
        amplifier: 0,
        showParticles: true
    };
    /**
     * * 实体效果选项
     */
    const effectOptions_30: server.EntityEffectOptions = {
        amplifier: 30,
        showParticles: true
    };
    /**
     * * 实体查询选项
     */
    const entityQueryOption: server.EntityQueryOptions = {
        excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:ender_dragon", "minecraft:ender_crystal"],
        location: dragon.location,
        maxDistance: 64
    };
    /**
     * * 附近的所有实体
     */
    const nearby = dragon.dimension.getEntities(entityQueryOption);
    /**
     * * 定义 坐标基准点
     */
    const vertex0 = math_tools.Vector.add(dragon.location, { x: 32, y: 5, z: 32 });
    /**
     * * 定义 坐标基准点
     */
    const vertex1 = math_tools.Vector.add(dragon.location, { x: -32, y: 32, z: -32 });
    // 触发随机效果
    switch (math_tools.Random({ min: 0, max: 23 }, true)) {
        case 1:
            player.applyKnockback(math_tools.Random({ min: -1, max: 1 }), math_tools.Random({ min: -1, max: 1 }), math_tools.Random({ min: 4, max: 16 }), math_tools.Random({ min: 4, max: 16 }));
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 龙之弹射 >');
            player?.addEffect("blindness", 40, effectOptions_0);
            break;

        case 3:
            nearby.forEach(entity => achieve_plan.RunePowerAttack.BriefCreate(entity, dragon, derived_tools.IsErupt(dragon)));
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 龙之威压 >');
            break;

        case 5:
            achieve_plan.RunePowerAttack.BriefCreate(player, dragon, derived_tools.IsErupt(dragon));
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 龙之反伤 >');
            break;

        case 7:
            player?.addEffect("weakness", 300, effectOptions_30);
            player?.addEffect("slow_falling", 300, effectOptions_30);
            player?.addEffect("mining_fatigue", 300, effectOptions_30);
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 眠龙之咒 >');
            break;

        case 9:
            player?.addEffect("blindness", 300, effectOptions_0);
            player?.addEffect("mining_fatigue", 300, effectOptions_30);
            player?.setOnFire(player.nameTag.length * damage, true);
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 禁忌之地 >');
            break;

        case 12:
            player?.addEffect("fatal_poison", 300, effectOptions_30);
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 龙牙之毒 >');
            break;

        default:
            native_tools.TrySpawnEntity(dragon.dimension, "minecraft:ender_crystal", math_tools.Vector.random(vertex0, vertex1));
            native_tools.TrySpawnEntity(dragon.dimension, "minecraft:ender_crystal", math_tools.Vector.random(vertex0, vertex1));
            native_tools.TrySpawnEntity(dragon.dimension, "minecraft:ender_crystal", math_tools.Vector.random(vertex0, vertex1));
            native_tools.TrySpawnEntity(dragon.dimension, "minecraft:ender_crystal", math_tools.Vector.random(vertex0, vertex1));
            native_tools.IntelMessage(dragon, 128, '< 龙鳞加护 : 群星璀璨 >');
            break;
    }
};
/**
 * * 实体攻击玩家后概率触发的效果
 * 
 * @param {server.Player} player - 触发实体损伤事件的玩家对象
 * 
 * @param { server.Entity} entity - 发动实体损伤事件的实体对象
 * 
 * @param {server.EntityEquippableComponent} equipment - 玩家对象的装备栏组件
 * 
 * @param {(server.ItemStack | undefined)[]} items - 玩家装备栏物品
 * 
 * @param {server.EquipmentSlot[]} slots - 玩家装备栏槽位
 */
export function EntityHurtPlayerAfterOddsTrigger(player: server.Player, entity: server.Entity, equipment: server.EntityEquippableComponent, items: (server.ItemStack | undefined)[], slots: server.EquipmentSlot[]) {
    /**
     * * 玩家背包容器
     */
    const container = player.getComponent('inventory')?.container;
    /**
     * * 背包随机索引
     */
    const containerRandom = math_tools.Random({ min: 0, max: container?.size ?? 27 }, true);
    /**
     * * 玩家主手选中的装备
     */
    const selectEquipment = container?.getItem(player.selectedSlotIndex);
    /**
     * * 装备随机索引
     */
    const equipmentRandom = math_tools.Random({ min: 0, max: items.length - 1 }, true);
    /**
     * * 随机装备
     */
    const randomEquipment = items[equipmentRandom];
    /**
     * * 随机装备的耐久
     */
    const randomEquipmentDurability = randomEquipment?.getComponent('durability');
    // 检测是否满足条件
    if (items.length >= 1) switch (entity.typeId) {
        // 原版-僵尸 特殊技能
        case 'minecraft:zombie':
            // 检测是否为精英怪物
            if (!GetEliteEnemy(entity)) break;
            // 检测是否满足其他条件
            if (!randomEquipment || !randomEquipmentDurability) break;
            // 使 被选中 的 装备 耐久-10
            randomEquipmentDurability.damage += 10;
            // 替换被选中的装备
            equipment?.setEquipment(slots[equipmentRandom], randomEquipment);
            // 显示提示文本
            player.sendMessage(
                [
                    native_tools.EntityTranslate(entity),
                    { text: '对您发动了< 腐化 > : ' },
                    native_tools.ItemTranslate(randomEquipment),
                    { text: ` §4§l耐久下降` }
                ]
            );
            break;

        // 原版-掠夺者 特殊技能
        case 'minecraft:pillager':
            // 检测是否为精英怪物
            if (!GetEliteEnemy(entity)) break;
            // 检测是否满足其他条件
            if (container) {
                /**
                 * * 背包随机物品
                 */
                const item = container.getItem(containerRandom);
                // 检测物品是否存在
                if (!item) break;
                // 移除背包中的物品
                container.setItem(containerRandom);
                // 在袭击者的位置上掉落物品
                native_tools.TrySpawnItem(entity.dimension, item, entity.location);
                // 显示提示文本
                player.sendMessage(
                    [
                        native_tools.EntityTranslate(entity),
                        { text: '对您发动了< 窃取 > :' },
                        native_tools.ItemTranslate(item),
                        { text: ` 已丢失 !!` }
                    ]
                )
            };
            break;

        // 原版-骷髅 特殊技能
        case 'minecraft:skeleton':
            // 检测是否为精英怪物
            if (!GetEliteEnemy(entity)) break;
            // 检测是否满足其他条件
            if (selectEquipment) {
                /**
                 * * 击退方向
                 */
                const direction = math_tools.Vector.difference(entity.location, player.location);
                /**
                 * * 本体与目标的距离
                 */
                const distance = math_tools.Vector.distance(entity.location, player.location);
                /**
                 * * 击退系数
                 */
                const mapping = (1 + distance / distance) * 3;
                // 执行击退
                player.applyKnockback(direction.x, direction.z, mapping, direction.y * 2);
                // 显示提示文本
                player.sendMessage(
                    [
                        native_tools.EntityTranslate(entity),
                        { text: '对您发动了< 强弓 >' }
                    ]
                )
            };
            break;

        // 原版-猪灵 特殊技能
        case 'minecraft:piglin':
            // 检测是否为精英怪物
            if (!GetEliteEnemy(entity)) break;
            // 检测是否满足其他条件
            if (entity.getEffect('resistance')?.amplifier) {
                /**
                 * * 实体过滤选项
                 */
                const options: server.EntityQueryOptions = {
                    type: 'minecraft:piglin',
                    closest: 4
                };
                /**
                 * * 实体排序
                 */
                const onSort = (entity0: server.Entity, entity1: server.Entity) => {
                    const distance0 = math_tools.Vector.distance(player.location, entity0.location);
                    const distance1 = math_tools.Vector.distance(player.location, entity1.location);
                    return distance0 - distance1;
                };
                /**
                 * * 实体筛选
                 */
                const onFilter = (target: server.Entity) => {
                    return target.getEffect('resistance')?.amplifier ?? 0 <= 2;
                };
                /**
                 * * 实体队列
                 */
                const entitys = native_tools.EntitysSort(player.dimension, options, onSort, onFilter);
                /**
                 * * 遍历 实体队列
                 */
                entitys.forEach(
                    target => {
                        const effect = target.getEffect('resistance')?.amplifier ?? -1;
                        target.addEffect('resistance', 300, { amplifier: effect + 1, showParticles: true });
                    }
                );
                // 显示提示文本
                player.sendMessage(
                    [
                        native_tools.EntityTranslate(entity),
                        { text: '对您发动了< 团结 > : ' },
                        native_tools.EntityTranslate(entity),
                        { text: ' 获得 < 抗性提升 > ' },
                    ]
                );
            }
            break;

        default: break;
    }
};
/**
 * * 判断实体是否为精英怪
 * 
 * @param {server.Entity} entity - 进行检测的实体对象
 * 
 * @returns {boolean} - 是否为精英怪
 */
function GetEliteEnemy(entity: server.Entity): boolean {
    /**
     * * 获取 实体 是否为 精英怪
     */
    const state = entity.getDynamicProperty('entity:elite_enemy_of_the_family');
    // 判断 状态 是否被创建
    if (state == undefined) {
        if (derived_tools.IsEnable(10)) {
            // 给与装备
            entity.runCommand('replaceitem entity @s slot.armor.head 0 turtle_helmet');
            entity.runCommand('replaceitem entity @s slot.weapon.offhand 0 shield');
            // 设置动态属性
            entity.setDynamicProperty('entity:elite_enemy_of_the_family', true);
            // 添加 状态效果
            entity.addEffect('fire_resistance', 20000000);
            return true;
        }
        else {
            // 设置动态属性
            entity.setDynamicProperty('entity:elite_enemy_of_the_family', false);
            return false;
        }
    }
    return state as boolean;
};
/**
 * * 茉莉 - 百花之祈
 * 
 * @param {server.Entity} entity - 执行事件的实体对象
 */
export function PrayerOfHundredFlowers(entity: server.Entity) {
    /**
     * * 实体查询选项
     */
    const options_amulet: server.EntityQueryOptions = {
        location: entity.location,
        families: ['amulet'],
        maxDistance: 4
    };
    /**
     * * 获取 强化法阵
     */
    const strengthen = entity.dimension.getEntities(options_amulet);
    if (!achieve_plan.ControlEventTrigger.EntityToken('茉莉:百花之祈', entity, 40)) return;
    if (strengthen.length == 0) return;
    /**
     * * 实体查询选项
     */
    const options_abyss: server.EntityQueryOptions = {
        location: entity.location,
        excludeFamilies: ['spirit'],
        families: ['abyss'],
        maxDistance: 32
    };
    /**
     * * 获取 相同阵营 的 实体
     */
    const entitys = entity.dimension.getEntities(options_abyss);
    entitys.forEach(
        entity => {
            /**
             * * 获取 实体生命值组件
             */
            const health = entity.getComponent('minecraft:health');
            health?.setCurrentValue(health.currentValue + 50);
            native_tools.TrySpawnParticle(entity.dimension, 'constant:pulse_rune_green', entity.location);
        }
    )
};
/**
 * * 野蜂机群 强制落地
 * 
 * @param {server.Entity} entity - 实体 野蜂维系者
 */
export function WaspClusterCrash(entity: server.Entity) {
    // 判断 是否 完成初始化
    if (!entity || !entity.isValid()) return;
    if (!entity.getDynamicProperty('entity:is_initial')) return;
    if (!achieve_plan.ControlEventTrigger.EntityToken('攻击冷却', entity, 40)) return;
    /**
     * * 实体查询选项
     */
    const options: server.EntityQueryOptions = {
        excludeTags: ['crash_after'],
        location: entity.location,
        families: ['wasp'],
        maxDistance: 24
    };
    /**
     * * 获取实体列表
     */
    const entitys = entity.dimension.getEntities(options);
    // 判断实体是否存在
    if (entitys.length == 0) return;
    entitys.forEach(
        entity => {
            /**
             * * 事件 - 野蜂坠落
             */
            const event = () => {
                if (entity && entity.isValid()) entity.applyKnockback(0, 0, 0.1, -1);
            };
            /**
             * * 计时器标识
             */
            const id = server.system.runInterval(() => event(), 1);
            // 添加标记 并播放 粒子效果
            entity.addTag('crash_after');
            server.system.runTimeout(() => server.system.clearRun(id), 200);
            native_tools.TrySpawnParticle(entity.dimension, 'constant:excite_rune_red', entity.location);
        }
    );
    // 播放 音效
    server.world.playSound('random.anvil_break', entity.location, { pitch: 1, volume: 0.5 });
};
/**
 * * 野蜂之王 呼叫增援
 * 
 * @param {server.Entity} entity - 实体 野蜂君临者
 */
export function WaspReinforce(entity: server.Entity) {
    /**
     * * * 获取 实体生命值组件
     */
    const health = entity.getComponent('health');
    // 当生命值低于 75% 时
    if (health && native_tools.HealthBelow(health, 0.75) && !entity.getDynamicProperty('wasp_emperor:health_75%')) {
        const energy = entity.getDynamicProperty('wasp_emperor:energy') as number ?? 0;
        entity.setDynamicProperty('wasp_emperor:energy', energy + 15);
        entity.setDynamicProperty('wasp_emperor:health_75%', true);
        entity.target?.addEffect('darkness', 40);
    };
    // 当生命值低于 50% 时
    if (health && native_tools.HealthBelow(health, 0.5) && !entity.getDynamicProperty('wasp_emperor:health_50%')) {
        const energy = entity.getDynamicProperty('wasp_emperor:energy') as number ?? 0;
        entity.setDynamicProperty('wasp_emperor:energy', energy + 15);
        entity.setDynamicProperty('wasp_emperor:health_50%', true);
        entity.target?.addEffect('darkness', 80);
    };
    // 当生命值低于 25% 时
    if (health && native_tools.HealthBelow(health, 0.25) && !entity.getDynamicProperty('wasp_emperor:health_25%')) {
        const energy = entity.getDynamicProperty('wasp_emperor:energy') as number ?? 0;
        entity.setDynamicProperty('wasp_emperor:energy', energy + 15);
        entity.setDynamicProperty('wasp_emperor:health_25%', true);
        entity.target?.addEffect('darkness', 160);
    };
    /**
     * * 实体能量值 - 生成前检测
     */
    const energy = entity.getDynamicProperty('wasp_emperor:energy') as number ?? 0;
    /**
     * * 随机移动 范围
     */
    const range = Math.random() * 4;
    // 判断是否满足条件
    if (energy < 15 || !entity.dimension.getBlock(entity.location)) return;
    // 随机移动
    server.system.runTimeout(() => entity.applyKnockback(Math.random(), Math.random(), range - 2, range * 2), 5);
    // 生成随机实体
    for (let index = 0; index < energy / 5; index++) {
        /**
         * * 解析 权重信息
         */
        const analysis = derived_tools.AnalysisWeight(data_entity.wasp_cluster_raid);
        // 生成 野蜂实体
        native_tools.TrySpawnEntity(entity.dimension, analysis.output, entity.location);
        /**
         * * 当前能量值 - 生成时检测
         */
        const value = entity.getDynamicProperty('wasp_emperor:energy') as number ?? 0;
        entity.setDynamicProperty('wasp_emperor:energy', value - 5);
    }
};
/**
 * * 渊鲸君临者 - 损伤定义
 * 
 * @param {server.Entity} entity - 实体 渊鲸君临者
 * 
 * @param {server.Player | server.Entity} player - 造成攻击的玩家
 */
export function DefineOfWhaleDamage(entity: server.Entity, player: server.Player | server.Entity) {
    /**
     * * 获取 实体生命值组件
     */
    const health = entity.getComponent('minecraft:health');
    /**
     * * 判断实体是否隐身
     */
    const isNotInvisible = entity.getEffects().every(effect => effect.typeId !== '隐身');
    /**
     * * 损伤定义的损耗值
     */
    const attrition = isNotInvisible ? 2000 : 20000;
    // 判断 是否满足 损伤定义 的 触发条件
    if (!achieve_plan.ControlEventTrigger.EntityToken('渊鲸君临者-损伤定义', entity, 20) || !health) return;
    // 播放 损伤定义音效
    if (player instanceof server.Player) WhaleDamageSoundEffect(entity, player, attrition);
    // 显示 损伤定义值
    health.setCurrentValue(health.currentValue - attrition);
};
/**
 * * 渊鲸侦查者 - 损伤定义
 *
 * @param {server.Player | server.Entity} player - 玩家对象
 */
export function DefineOfWhaleAdjudication(player: server.Player | server.Entity) {
    // 判断 是否满足 损伤定义 的 触发条件
    if (!derived_tools.IsEnable(15) || !(player instanceof server.Player)) return;
    // 为玩家设定[黑暗]效果
    player.addEffect('darkness', 40, { showParticles: false });
    // 为玩家设定[君王圣裁]标记
    player.setDynamicProperty('whale_adjudication', true);
    // 播放 损伤定义音效
    player.playSound('mob.elderguardian.curse');
};
/**
 * * 渊鲸君临者 损伤定义 音效
 * 
 * @param {server.Entity} entity - 实体 渊鲸君临者
 * 
 * @param {server.Player | server.Entity} player - 造成攻击的玩家
 * 
 * @param {number} attrition - 损伤定义的损耗值
 */
function WhaleDamageSoundEffect(entity: server.Entity, player: server.Player, attrition: number) {
    // 判断 伤害数值 是否是 特攻伤害
    switch (attrition) {
        case 20000:
            // 概率性 清除 隐身效果
            if (derived_tools.IsEnable(50)) entity.addEffect('invisibility', 1, { amplifier: 9, showParticles: true });
            // 生成 粒子效果
            native_tools.TrySpawnParticle(entity.dimension, 'constant:disperse_rune_blue', entity.getHeadLocation());
            native_tools.TrySpawnParticle(entity.dimension, 'constant:impact_rune_blue', entity.getHeadLocation());
            native_tools.TrySpawnParticle(entity.dimension, 'constant:excite_rune_blue', entity.getHeadLocation());
            // 播放 特攻音效
            player.playSound('item.trident.thunder');
            break;

        default:
            // 播放命中音效
            server.system.run(() => player.playSound('random.anvil_land'));
            player.playSound('ambient.weather.lightning.impact');
            // 君临者 随机隐身
            WhaleRandomStealth(entity, player);
            break;
    };
    // 生成粒子效果
    native_tools.TrySpawnParticle(entity.dimension, 'constant:erupt_rune_blue', entity.getHeadLocation());
};
/**
 * * 渊鲸君临者 随机隐身
 * 
 * @param {server.Entity} entity - 实体 渊鲸君临者
 * 
 * @param {server.Player | server.Entity} player - 造成攻击的玩家
 */
function WhaleRandomStealth(entity: server.Entity, player: server.Player) {
    // 判断 是否满足 隐身 的 触发条件
    if (!derived_tools.IsEnable(10)) return;
    /**
     * * 获取 实体位置
     */
    const copyEntityLocation = math_tools.Vector.copy(entity.getHeadLocation());
    /**
     * * 获取 玩家位置
     */
    const copyPlayerLocation = math_tools.Vector.copy(player.getHeadLocation());
    /**
     ** 粒子射流方向
     */
    const direction = math_tools.Vector.difference(copyEntityLocation, copyPlayerLocation);
    /**
     * * 定义 粒子参数
     */
    const molang = new server.MolangVariableMap();
    // 设置 粒子参数
    molang.setVector3('variable.direction', direction);
    molang.setFloat('variable.type', 0);
    // 移动实体
    entity.teleport(copyPlayerLocation);
    player.teleport(copyEntityLocation);
    // 生成粒子效果
    native_tools.TrySpawnParticle(entity.dimension, 'constant:disperse_rune_blue', copyPlayerLocation);
    native_tools.TrySpawnParticle(entity.dimension, 'constant:pulse_rune_blue', copyPlayerLocation);
    native_tools.TrySpawnParticle(entity.dimension, 'scripts:path_ray', copyEntityLocation, molang);
    // 附加状态效果
    entity.addEffect('invisibility', 300, { amplifier: 0, showParticles: true });
    // 播放 隐身音效
    server.system.run(() => player.playSound('item.trident.thunder'));
    // 生成 渊鲸实体
    native_tools.TrySpawnEntity(entity.dimension, "entity_machine:whale_detection", math_tools.Vector.random(entity.location, player.location));
    native_tools.TrySpawnEntity(entity.dimension, "entity_machine:whale_detection", math_tools.Vector.random(entity.location, player.location));
    native_tools.TrySpawnEntity(entity.dimension, "entity_machine:whale_detection", math_tools.Vector.random(entity.location, player.location));
};